Find the length of the longest strictly increasing subsequence in an array
Determine the length of the longest strictly increasing subsequence in an array to identify sorted patterns.
Array:
LIS Length: 3 (e.g., [1, 8, 16])
LIS Length: 2 (e.g., [1, 2])
| Index | 0 | 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|---|
| Element | 5 | 4 | 11 | 1 | 16 | 8 |
| DP Value | 1 | 1 | 2 | 1 | 3 | 2 |
LIS Length: 3 (e.g., [1, 8, 16])
For nested loops over N elements
For DP array
Example 1: nums = [5, 4, 11, 1, 16, 8] ā Length of the longest increasing subsequence: 3
Example 2: nums = [1, 2, 2] ā Length of the longest increasing subsequence: 2
For nested loops over N elements
For DP array